package com.platform.module.dao.service.impl;

import com.platform.module.dao.entity.TbUserPay;
import com.platform.module.dao.mapper.TbUserPayMapper;
import com.platform.module.dao.service.TbUserPayService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * <p>
 * 用户充值提现表 服务实现类
 * </p>
 *
 * @author ZM
 * @since 2025-01-07
 */
@Service
@AllArgsConstructor
public class TbUserPayServiceImpl extends ServiceImpl<TbUserPayMapper, TbUserPay> implements TbUserPayService {

    private final TbUserPayMapper tbUserPayMapper;

    public BigDecimal sumImoneyByUserIdAndItypeAndIsSuccessAndCcreateTime(Long userId, Integer itype, Integer isSuccess, LocalDate createTime) {
        BigDecimal sumImoney = tbUserPayMapper.sumImoneyByUserIdAndItypeAndIsSuccessAndCcreateTime(userId, itype, isSuccess, createTime);
        return sumImoney != null ? sumImoney : BigDecimal.ZERO;
    }

    @Override
    public BigDecimal sumImoneyByUserIdAndItypeAndIsSuccessAndCcreateTimeBetween(Long userId, Integer itype, Integer isSuccess, LocalDateTime cumulativeStartTime, LocalDateTime cumulativeExpiredTime) {
        BigDecimal sumImoney = tbUserPayMapper.sumImoneyByUserIdAndItypeAndIsSuccessAndCcreateTimeBetween(userId, itype, isSuccess, cumulativeStartTime,cumulativeExpiredTime);
        return sumImoney != null ? sumImoney : BigDecimal.ZERO;
    }
}